package com.ms.game.characterInfo.db;

import java.sql.Date;

import com.ms.game.characterInfo.CharacterInfoProcessor;
import com.ms.game.characterInfo.message.CharacterInfoResponse;
import com.ms.service.module.account.db.AccountDAO;
import com.xpec.c4.db.dao.PlayerDAO;
import com.xpec.c4.game.time.TimeSys;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

public class LoadCharacterInfoAsync extends TaskAsyncCommand {

	public GUID accountID;
	
	public GUID playerID;
	
	/**
	 * 點數
	 */
	public Long cash;
	
	public GUID sessionID;
	
	/**
	 * 回傳消息
	 */
	public CharacterInfoResponse response;
	
	@Override
	public void asyncExecute() throws Exception {
		//讀取帳號點數
		cash = AccountDAO.loadCashByAccountId(accountID);
		
		//轉sql_date只抓取當日的記錄 
		Date date= new Date(TimeSys.currentTimeMills());
		
		//讀取今日押注記錄，今日得分紀錄
		CharacterTodayInfoLog dailyInfo= CharacterInfoLogDAO.loadTodayBetInfoByGuid(playerID, date);
		if(dailyInfo != null){
			response.todayBet = dailyInfo.dailyBet.toString();
			response.todayScore = dailyInfo.dailyScore.toString();
		}
		
		response.playerIdentityType = PlayerDAO.getPlayerIdentityTypeByPlayerId(playerID.toString());
		
		response.cash = cash;
	}

	@Override
	public void execute() throws Exception {
		CharacterInfoProcessor.OnGetCharacterInfoCallBack(response , sessionID);
	}

}
